import java.util.Scanner;
import java.util.Vector;

public class Main5 {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        Vector<Integer> officeOpenDay = new Vector<>();
        Vector<Integer> gymOpenDay = new Vector<>();
        int t = n;
        while (t != 0) {
            t--;
            officeOpenDay.add(s.nextInt());
        }
        t = n;
        while (t != 0) {
            t--;
            gymOpenDay.add(s.nextInt());
        }
        int restday = 0;
        boolean officeAlready = false, gymAlready = false;
        for (int i = 0; i < n; i++) {
            if (officeOpenDay.get(i) == 1 && !officeAlready) {
                officeAlready = true;
                gymAlready = false;
            } else if (gymOpenDay.get(i) == 1 && !gymAlready) {
                gymAlready = true;
                officeAlready = false;
            } else {
                restday++;
                gymAlready = false;
                officeAlready = false;
            }

        }
        System.out.println(restday);
    }
}
